const tokenName = "zxd-token";
const userInfo = "zxd-user";
const menus = "zxd-menus";
const area = "AREA";

export function setToken(value) {
  if (value) {
    sessionStorage.setItem(tokenName, value);
  } else {
    sessionStorage.removeItem(tokenName);
  }
}
export function getToken() {
  return sessionStorage.getItem(tokenName);
}

export function setUser(value) {
  if (value) {
    sessionStorage.setItem(userInfo, JSON.stringify(value));
  } else {
    sessionStorage.removeItem(userInfo);
  }
}
export function getUser() {
  return JSON.parse(sessionStorage.getItem(userInfo));
}

export function setMenus(value) {
  if (value) {
    sessionStorage.setItem(menus, JSON.stringify(value));
  } else {
    sessionStorage.removeItem(menus);
  }
}
export function getMenus() {
  return JSON.parse(sessionStorage.getItem(menus));
}
export function getArea() {
  return JSON.parse(localStorage.getItem(area));
}
export function setArea(val) {
  return localStorage.setItem(area, JSON.stringify(val));
}

export function getLocalStorage(key) {
  return JSON.parse(localStorage.getItem(key));
}
export function setLocalStorage(key, val) {
  return localStorage.setItem(key, JSON.stringify(val));
}
